<?php

class UserCollectController extends BaseController
{
    protected $tableName = "user_collect";
    protected $pk = "collect_id";

    // 收藏添加文章
    public function post($obj)
    {
        $user_id = $obj['user_id'];
        $answer_id = $obj['answer_id'];
        $sql = "INSERT INTO user_collect VALUES(0, $user_id, $answer_id, CURRENT_TIME)";
        $result = $this->conn->query($sql);
        if ($this->judge($result)) {
            return ReturnHelper::success($this->getNewRecord($obj),"用户`$user_id`收藏回答`$answer_id`成功");

        }
        else {
            return ReturnHelper::failed([], "用户`$user_id`收藏回答`$answer_id`失败");
        }
    }
}